import { createApp } from "vue";
import "./assets/css/base.css";
import "./assets/css/style.css";
import "./assets/font/iconfont.css";
import "./assets/css/djhs.css";

import router from "./router";
import kxApp from "./kxApp.vue";
import axApp from "./axApp.vue";
import App from "./App.vue";
import store from "./store";
import dxPeer from "./store/dxPeer";
let app = createApp(App);
 import "./rem.js"
import directive from "./directive";
import configFun from "./configFun";
import naive from "./plus/naive";
import { dynamicLoadJs } from "./util/index";

import { Onfun } from "./websocket/index";

switch (import.meta.env.VITE_type) {
  case "kx":
    app = createApp(kxApp);
    break;
  case "ax":
    app = createApp(axApp);
    break;
}
if (import.meta.env.VITE_type != "kx"&& import.meta.env.VITE_type !='jk') {
  Onfun(localStorage.userNmae);
}
// import { createStore } from "./peerjs/dxstore";
// const dxstore = createStore();
directive(app); // 自定义指令
configFun(app); // 全局方法
naive(app); // naive ui
var Width =
  window.innerWidth ||
  document.documentElement.clientWidth ||
  document.body.clientWidth;
store.state.windowSize = Width;
// 对vue进行类型补充说明
declare module "@vue/runtime-core" {
  interface ComponentCustomProperties {
    $MU: any;
    $toFixed: any;
    $AU: any;
  }
}

// dxstore.action.initPeerAct(localStorage.userNmae);
// if (localStorage.userNmae) {
//   dxPeer.commit("initPeerJs", localStorage.userNmae);
// }

/**
 * 全局定时器
 *  页面上这样调用
 * js
    const currentTime = computed(() => {
        return store.state.currentTime;
    });
    模块   {{ transferTimeYMDHm(currentTime) }}  或 <div :data-time="currentTime"></div>
 */
setInterval(() => {
  store.state.currentTime = new Date().getTime();
}, 3000);

if (localStorage.id == 32) {
  let url =
    "//duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/kangsheng/LodopFuncs.js";
  dynamicLoadJs(url, () => {
    setTimeout(() => {
      window.LODOP = getLodop();
    }, 3000);
  });
}

app.use(router);
app.use(store);

app.mount("#app");
